<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
     <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>

    <script>
        let lis  =  document.querySelectorAll('li')
        for (let u = 0; u < lis.length; u++) {
            lis[u].onclick=function(){
                // 派他思想
                // 先删掉所有
            let chi =   this.parentNode.children
            for (let i = 0; i <chi.length; i++) {
                chi[i].style.background=''
                
            }
                this.style.background = 'red'
            }
            
        }
    </script>
</body>
</html>